home *** CD-ROM | disk | FTP | other *** search
/ Clickx 115 / Clickx 115.iso / software / tools / windows / tails-i386-0.16.iso / live / filesystem.squashfs / usr / share / doc / obfsproxy / protocol-spec.txt < prev    next >
Encoding:
Text File  |  2012-04-14  |  3.6 KB  |  104 lines

  1.         obfs2 (The Twobfuscator)
  2.  
  3. 0. Protocol overview
  4.  
  5.    This is a protocol obfuscation layer for TCP protocols.  Its purpose
  6.    is to keep a third party from telling what protocol is in use based
  7.    on message contents.  It is based on brl's ssh obfuscation protocol.
  8.  
  9.    It does not provide authentication or data integrity.  It does not
  10.    hide data lengths.  It is more suitable for providing a layer of
  11.    obfuscation for an existing authenticated protocol, like SSH or TLS.
  12.  
  13.    The protocol has two phases: in the first phase, the parties
  14.    establish keys.  In the second, the parties exchange superenciphered
  15.    traffic.
  16.  
  17. 1. Primitives, notation, and constants.
  18.  
  19.     H(x) is SHA256 of x.
  20.     H^n(x) is H(x) called iteratively n times.
  21.  
  22.     E(K,s) is the AES-CTR-128 encryption of s using K as key.
  23.  
  24.     x | y is the concatenation of x and y.
  25.     UINT32(n) is the 4 byte value of n in big-endian (network) order.
  26.     SR(n) is n bytes of strong random data.
  27.     WR(n) is n bytes of weaker random data.
  28.     "xyz" is the ASCII characters 'x', 'y', and 'z', not NUL-terminated.
  29.     s[:n] is the first n bytes of s.
  30.     s[n:] is the last n bytes of s.
  31.  
  32.     MAGIC_VALUE      is  0x2BF5CA7E
  33.     SEED_LENGTH      is  16
  34.     MAX_PADDING      is  8192
  35.     HASH_ITERATIONS  is  100000
  36.  
  37.     KEYLEN is the length of the key used by E(K,s) -- that is, 16.
  38.     IVLEN is the length of the IV used by E(K,s) -- that is, 16.
  39.  
  40.     HASHLEN is the length of the output of H() -- that is, 32.
  41.  
  42.     MAC(s, x) = H(s | x | s)
  43.  
  44.     A "byte" is an 8-bit octet.
  45.  
  46.     We require that HASHLEN >= KEYLEN + IVLEN
  47.  
  48. 2. Key establishment phase.
  49.  
  50.    The party who opens the connection is the 'initiator'; the one who
  51.    accepts it is the 'responder'.  Each begins by generating a seed
  52.    and a padding key as follows.  The initiator generates:
  53.  
  54.     INIT_SEED = SR(SEED_LENGTH)
  55.     INIT_PAD_KEY = MAC("Initiator obfuscation padding", INIT_SEED)[:KEYLEN]
  56.  
  57.    And the responder generates:
  58.  
  59.     RESP_SEED = SR(SEED_LENGTH)
  60.     RESP_PAD_KEY = MAC("Responder obfuscation padding", INIT_SEED)[:KEYLEN]
  61.  
  62.    Each then generates a random number PADLEN in range from 0 through
  63.    MAX_PADDING (inclusive).
  64.  
  65.    The initiator then sends:
  66.  
  67.     INIT_SEED | E(INIT_PAD_KEY, UINT32(MAGIC_VALUE) | UINT32(PADLEN) | WR(PADLEN))
  68.  
  69.    and the responder sends:
  70.  
  71.     RESP_SEED | E(RESP_PAD_KEY, UINT32(MAGIC_VALUE) | UINT32(PADLEN) | WR(PADLEN))
  72.  
  73.    Upon receiving the SEED from the other party, each party derives
  74.    the other party's padding key value as above, and decrypts the next
  75.    8 bytes of the key establishment message.  If the MAGIC_VALUE does
  76.    not match, or the PADLEN value is greater than MAX_PADDING, the
  77.    party receiving it should close the connection immediately.
  78.    Otherwise, it should read the remaining PADLEN bytes of padding data
  79.    and discard them.
  80.  
  81.    Additional keys are then derived as:
  82.  
  83.      INIT_SECRET = MAC("Initiator obfuscated data", INIT_SEED|RESP_SEED)
  84.      RESP_SECRET = MAC("Responder obfuscated data", INIT_SEED|RESP_SEED)
  85.      INIT_KEY = INIT_SECRET[:KEYLEN]
  86.      INIT_IV = INIT_SECRET[KEYLEN:]
  87.      RESP_KEY = RESP_SECRET[:KEYLEN]
  88.      RESP_IV = RESP_SECRET[KEYLEN:]
  89.  
  90.    The INIT_KEY value keys a stream cipher used to encrypt values from
  91.    initiator to responder thereafter.  The stream cipher's IV is
  92.    INIT_IV.  The RESP_KEY value keys a stream cipher used to encrypt
  93.    values from responder to initiator thereafter.  That stream cipher's
  94.    IV is RESP_IV.
  95.  
  96. 3. Shared-secret extension
  97.  
  98.    Optionally, if the client and server share a secret value SECRET,
  99.    they can replace the MAC function with:
  100.  
  101.       MAC(s,x) = H^n(s | x | H(SECRET) | s)
  102.  
  103.    where n = HASH_ITERATIONS.
  104.